pg_query is error -> select *, case when get_img_count(regist_cd)>0 then 1 else 0 end as image_flag, to_char(open_day , 'yyyy.mm.dd') as open_day_ymd, to_char(update_day , 'yyyy.mm.dd') as update_day_ymd, to_char(regist_day , 'yyyy.mm.dd') as regist_day_ymd, to_char(pledge_day , 'yyyy.mm.dd') as pledge_day_ymd, to_char(update_day , 'yyyy/mm/dd') as update_day_ymd_sl, to_char(regist_day , 'yyyy/mm/dd') as regist_day_ymd_sl, to_char(pledge_day , 'yyyy/mm/dd') as pledge_day_ymd_sl, (to_number(to_char(open_house_d_from,'mm'),'99')||'·î'||to_number(to_char(open_house_d_from,'dd'),'99')||'Æü') as open_house_d_from, (to_number(to_char(open_house_d_to,'mm'),'99')||'·î'||to_number(to_char(open_house_d_to,'dd'),'99')||'Æü') as open_house_d_to, to_char(moto_conf_day , 'yyyy.mm.dd') as moto_conf_day_ymd, get_addr_name(null,null,choume_cd,null) as shozaichi, get_rosen_name(rosen_cd1) as rosen_name1, get_eki_name(eki_cd1) as eki_name1, case when cast(regist_day as date) > cast((now() - interval '7 days') as date) then 1 else 0 end as newf, case when movie_url is not null and movie_url!='' then 1 else 0 end as movief, case when cast(open_house_d_from as date) >= cast(now() as date) then 1 else 0 end as openf, case when koukai_flag=3 then 1 else 0 end as kanbaif, count(koukai_flag) over (partition by koukai_flag) as koukai_cnt, count(regist_cd) over() as all_cnt from v_search_object where regist_cd > '0' and koukai_flag in (1,2,8,11) and substr(shop_cd,1,3)='064' and shop_cd not in ('06406') and shubetu_cd in (1,2,3,4,5,6) and regist_day >= TO_TIMESTAMP('' obj.searchday ' 000000' ,'yyyymmddhh24miss') and regist_day <= TO_TIMESTAMP('' obj.searchday ' 235959' ,'yyyymmddhh24miss') order by price_from , price_to, update_day desc offset 0 limit 20